package com.example.dormmanage.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.dormmanage.entity.Move;
import com.example.dormmanage.service.impl.MoveService;
import com.example.dormmanage.view.ResultView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/move")
@Api(tags = "迁移管理")
@Slf4j
public class MoveController {

    @Autowired
    private MoveService moveService;

    @GetMapping
    @ApiOperation("管理员查询迁移列表")
    public ResultView<Page> selectMoveList(Integer page, Integer pageSize, Integer buildingId, String studentName){
        return moveService.selectMoveList(page,pageSize,buildingId,studentName);
    }

    @GetMapping("/student")
//    @PreAuthorize("hasAuthority('selectBuildingList')")
    @ApiOperation("学生查询迁移列表")
    public ResultView<Page> selectMoveList(Integer page, Integer pageSize){
        return moveService.selectMoveList(page,pageSize);
    }

    @PostMapping()
    @ApiOperation("新增迁移记录")
    public ResultView<String> addMove(@RequestBody Move move){
        return moveService.addMove(move);
    }

    @PutMapping("/{moveId}/{status}")
    @ApiOperation("迁移审核")
    public ResultView<String> checkMove(@PathVariable Long moveId, @PathVariable Integer status){
        return moveService.checkMove(moveId,status);
    }
}
